package com.hg.common.enums;

import lombok.Getter;

@Getter
public enum ResultEnum {
	SUCCESS(1, "成功"),
	SYSTEM_ERROR(2, "系统出现异常,请联系管理员"),
	PARAM_ERROR(3, "参数不正确"),
	PARAM_VALIDATE_ERROR(4,"参数校验失败"),
	ID_IS_NULL(5,"Id不能为空"),

	DEPT_NAME_DUPLICATE(100,"同级部门下已经存在相同名称的部门"),
	HAVE_CHILD_DEPT(101,"当前部门下面有子部门,无法删除"),
	DEPT_NOT_EXIST(102,"部门不存在")
	;

	private Integer code;
	private String message;

	ResultEnum(Integer code, String message) {
		this.code = code;
		this.message = message;
	}
	
	public static ResultEnum stateOf(int index) {
		for (ResultEnum state : values()) {
			if (state.getCode() == index) {
				return state;
			}
		}
		return null;
	}
}